package com.example.customview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

/**
 *
 */
public class TranslateCanvasView extends View {
    public TranslateCanvasView(Context context) {
        super(context);
    }

    public TranslateCanvasView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
//        super.onDraw(canvas);
        Paint paint = new Paint();
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(5);
        paint.setColor(Color.RED);
        canvas.translate(100,100);
        //save 保存当前的绘制坐标系
        canvas.save();
        canvas.rotate(90);
        //restore 销毁坐标系,还原到上一次保存的坐标系效果
        canvas.restore();
        canvas.drawLine(0,0,100,0,paint);
    }
}
